/*********************************************************************************/
/*                                                                               */
/*      PORT Driver                                                              */
/*                                                                               */
/*      Last updated by:   CBS                                                   */
/*      Last update date:  2013/1/25                                             */
/*      Revision:          0                                                     */
/*      Copyright:         DENS0                                                 */
/*                                                                               */
/*********************************************************************************/

#ifndef PORT_CFG_H_
#define PORT_CFG_H_

/*********************************************************************************/
/*  include files                                                                */
/*********************************************************************************/
#include "Std_Types.h"
#include "MPC5674F_MVx264.h"


#define PORT_VERSION_INFO_API               STD_ON
#define PORT_DEV_ERROR_DETECT               STD_ON
#define PORT_SET_PIN_MODE_API               STD_ON
#define PORT_SET_PIN_DIRECTION_API          STD_ON



#define   PORT_BIT0       (1<<15)
#define   PORT_BIT1       (1<<14)
#define   PORT_BIT2       (1<<13)
#define   PORT_BIT3       (1<<12)
#define   PORT_BIT4       (1<<11)
#define   PORT_BIT5       (1<<10)
#define   PORT_BIT6       (1<<9)
#define   PORT_BIT7       (1<<8)
#define   PORT_BIT8       (1<<7)
#define   PORT_BIT9       (1<<6)
#define   PORT_BIT10      (1<<5)
#define   PORT_BIT11      (1<<4)
#define   PORT_BIT12      (1<<3)
#define   PORT_BIT13      (1<<2)
#define   PORT_BIT14      (1<<1)
#define   PORT_BIT15      (1<<0)


/*PCR bit field*/
#define   PORT_WPS_BIT        PORT_BIT15
#define   PORT_WPE_BIT        PORT_BIT14
#define   PORT_SRC0_BIT       PORT_BIT13
#define   PORT_SRC1_BIT       PORT_BIT12
#define   PORT_HYS_BIT        PORT_BIT11
#define   PORT_ODE_BIT        PORT_BIT10
#define   PORT_DSC0_BIT       PORT_BIT9
#define   PORT_DSC1_BIT       PORT_BIT8
#define   PORT_IBE_BIT        PORT_BIT7
#define   PORT_OBE_BIT        PORT_BIT6
#define   PORT_PA0_BIT        PORT_BIT5
#define   PORT_PA1_BIT        PORT_BIT4
#define   PORT_PA2_BIT        PORT_BIT3


/*Mode Selection*/
#define   PORT_PA_IO                     (0)
#define   PORT_PA_PRIMARY_FUNC           (PORT_PA0_BIT)
#define   PORT_PA_ALTERNATE_FUNC1        (PORT_PA1_BIT)
#define   PORT_PA_ALTERNATE_FUNC2        (PORT_PA1_BIT|PORT_PA0_BIT)
#define   PORT_PA_ALTERNATE_FUNC3        (PORT_PA2_BIT)

/*Drive Strength Control*/
#define   DRIVE_STRENGTH_10pF            (0)
#define   DRIVE_STRENGTH_20pF            (PORT_DSC0_BIT)
#define   DRIVE_STRENGTH_30pF            (PORT_DSC1_BIT)
#define   DRIVE_STRENGTH_50pF            (PORT_DSC1_BIT|PORT_DSC0_BIT)

/*Open Drain Enable*/
#define   PORT_ODE_ENABLE                (PORT_ODE_BIT)

/*Input Hysteresis*/
#define   PORT_HYS_ENABLE                (PORT_HYS_BIT)

/*Slew Rate Control*/
#define   PORT_SLEW_RATE_MIN             (0)
#define   PORT_SLEW_RATE_MED             (PORT_SRC0_BIT)
#define   PORT_SLEW_RATE_MAX             (PORT_SRC1_BIT|PORT_SRC0_BIT)

/*Weak PullUp/PullDown Enable*/
#define   PORT_PULL_ENABLE               (PORT_WPE_BIT)
#define   PORT_PULL_DISABLE              (0)


/*Weak PullUp/PullDown Select*/
#define   PORT_PULL_UP                   (PORT_WPS_BIT)
#define   PORT_PULL_DOWN                 (0)


/*Port Pin Direction*/
#define   PORT_OBE_ENABLE                (PORT_OBE_BIT)
#define   PORT_IBE_ENABLE                (PORT_IBE_BIT)
#define   PORT_IO_INPUT                  (PORT_IBE_ENABLE|PORT_PULL_DOWN)
#define   PORT_IO_OUTPUT                 (PORT_OBE_ENABLE)


#define   PORT_PCR_RESET                 (0)
#define   PORT_GPDO_RESET                (0)
#define   PORT_GPDO_LOW                  (0)
#define   PORT_GPDO_HIGH                 (1)
#define   PORT_PIN_TOTAL_NUM             (sizeof(SIU.PCR)/sizeof(U2))


#define   PORT_DIRECTION_CHANGEABLE      (TRUE)        /*Port_RefreshPortDirection is permitted*/
#define   PORT_DIRECTION_UNCHANGEABLE    (FALSE)       /*Port_RefreshPortDirection is forbidden*/
#define   PORT_MODE_CHANGEABLE           (TRUE)        /*Port_SetPinMode is permitted*/
#define   PORT_MODE_UNCHANGEABLE         (FALSE)       /*Port_SetPinMode is forbidden*/


typedef U1 GPDO_CfgType;
typedef U2 PCR_CfgType;
typedef boolean PORT_PinDirCfgType;
typedef boolean PORT_PinModeCfgType;


typedef struct
{
  U2 PinTotalNum;
  const PCR_CfgType *padConfig;
  const GPDO_CfgType *outConfig;
  const PORT_PinDirCfgType *pinDirConfig;
  const PORT_PinModeCfgType *pinModeCfgType;

} Port_ConfigType;

extern const Port_ConfigType PortConfigData;




#endif /*PORT_CFG_H_*/
